home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
(A)Z
/
(A)Z9.ADF
/
Joke
/
joke.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-07-05
|
4KB
|
143 lines
/* A lightbulb joke making program. This isn't AI, but then, what is? */
/* Ported to the Amiga with no changes by John Foust */
#include <time.h>
#include <stdio.h>
#define MAXT 20
char plist[100][32], alist[100][32], tlist[100][32];
long random() {
long foo;
foo = rand() * rand();
if (foo<0) {
foo = (-foo);
}
return( foo );
}
main(argc,argv)
int argc;
char *argv[];
{
long ltime;
int people, action, things, total, first, rest, np, na, nt;
np = 0;
strcpy(plist[np++],"<ethnics>");
strcpy(plist[np++],"Doctors");
strcpy(plist[np++],"JAPs");
strcpy(plist[np++],"Lawyers");
strcpy(plist[np++],"Martians");
strcpy(plist[np++],"Newfoundlanders");
strcpy(plist[np++],"Programmers");
strcpy(plist[np++],"Students");
strcpy(plist[np++],"Yuppies");
strcpy(plist[np++],"Zen Masters");
strcpy(plist[np++],"Politicians");
strcpy(plist[np++],"DEC repairmen");
strcpy(plist[np++],"Russians");
strcpy(plist[np++],"Americans");
strcpy(plist[np++],"Canadians");
strcpy(plist[np++],"Nuns");
strcpy(plist[np++],"Priests");
strcpy(plist[np++],"Professors");
strcpy(plist[np++],"Californians");
na = 0;
strcpy(alist[na++],"build");
strcpy(alist[na++],"call");
strcpy(alist[na++],"change");
strcpy(alist[na++],"cook");
strcpy(alist[na++],"eat");
strcpy(alist[na++],"fix");
strcpy(alist[na++],"fly");
strcpy(alist[na++],"make");
strcpy(alist[na++],"move");
strcpy(alist[na++],"play");
strcpy(alist[na++],"watch");
strcpy(alist[na++],"tell");
strcpy(alist[na++],"love");
strcpy(alist[na++],"kill");
strcpy(alist[na++],"pick");
strcpy(alist[na++],"climb");
strcpy(alist[na++],"write");
strcpy(alist[na++],"save");
strcpy(alist[na++],"shop");
strcpy(alist[na++],"find");
nt = 0;
strcpy(tlist[nt++],"VAX");
strcpy(tlist[nt++],"IBM PC");
strcpy(tlist[nt++],"telephone");
strcpy(tlist[nt++],"subroutine");
strcpy(tlist[nt++],"house");
strcpy(tlist[nt++],"thesis");
strcpy(tlist[nt++],"nose");
strcpy(tlist[nt++],"Grizzly Bear");
strcpy(tlist[nt++],"light bulb");
strcpy(tlist[nt++],"birthday cake");
strcpy(tlist[nt++],"flat tire");
strcpy(tlist[nt++],"trumpet");
strcpy(tlist[nt++],"movie");
strcpy(tlist[nt++],"airplane");
strcpy(tlist[nt++],"book");
strcpy(tlist[nt++],"TV show");
strcpy(tlist[nt++],"Lisp program");
strcpy(tlist[nt++],"C program");
strcpy(tlist[nt++],"Fortran program");
strcpy(tlist[nt++],"cat");
strcpy(tlist[nt++],"hockey game");
strcpy(tlist[nt++],"dog");
strcpy(tlist[nt++],"fish");
strcpy(tlist[nt++],"UNIX system");
strcpy(tlist[nt++],"video game");
strcpy(tlist[nt++],"baseball bat");
strcpy(tlist[nt++],"Lightbulb joke");
strcpy(tlist[nt++],"frog");
strcpy(tlist[nt++],"compiler");
strcpy(tlist[nt++],"nuclear bomb");
strcpy(tlist[nt++],"cruise missile");
strcpy(tlist[nt++],"tree");
strcpy(tlist[nt++],"whale");
srand( (int)time(<ime));
people = random() % np;
action = random() % na;
things = random() % nt;
printf ("How many %s does it take to %s a %s?\n",
plist[people],alist[action],tlist[things]);
total = 1 + (random() % MAXT);
first = 1 + (random() % total);
rest = total - first;
action = random() % na;
things = random() % nt;
if (total == 1) {
printf ("Just one. Why should it take any more?\n");
}
else {
printf ("%d. %d to %s the %s, ",
total,first,alist[action],tlist[things]);
action = random() % na;
things = random() % nt;
printf ("and %d to %s the %s.\n",
rest,alist[action],tlist[things]);
}
exit(0);
}